import request from '~/utils/resquest'

// 根据用户名登录
export const loginByUsername = <T>(params: T & { key?: string; code?: string }) =>
  request({
    url: '/api/gxsaas-auth/token',
    method: 'post',
    headers: {
      'Captcha-Key': params.key!,
      'Captcha-Code': params.code!
    },
    params
    // data: params
  })

// 刷新用户登陆状态
export const refreshUserLogin = <T>(params: T) =>
  request({
    url: '/api/gxsaas-auth/token',
    method: 'post',
    params
    // data: params
  })

// 获取按钮
export const getButtons = () =>
  request({
    url: '/api/gxsaas-system/menu/buttons',
    method: 'get'
  })

// 获取用户信息
export const getUserInfo = () =>
  request({
    url: '/api/user/getUserInfo',
    method: 'get'
  })

export const registerGuest = <T>(params: T) =>
  request({
    url: '/api/gxsaas-system/user/register-guest',
    method: 'post',
    params
  })

// 获取系统菜单
export const getMenu = () =>
  request({
    url: '/api/gxsaas-system/menu/tenantRoutes',
    method: 'get'
  })

export const getCaptcha = () =>
  request({
    url: '/api/gxsaas-auth/captcha',
    method: 'get'
  })

// 获取顶部菜单
export const getTopMenu = () =>
  request({
    url: '/api/user/getTopMenu',
    method: 'get'
  })

// 获取租户设置的坐标
export const getCurrentTenant = () =>
  request({
    url: '/api/gxsaas-system/tenant/getCurrentTenant',
    method: 'get'
  })

//  修改密码
export const getUserUpdatePassword = <T>(params: T) =>
  request({
    url: '/api/gxsaas-system/user/update-password',
    method: 'post',
    params
  })
